package com.c.ctgproject.adapter.service

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.c.ctgproject.R
import com.c.ctgproject.wiget.dialog.ShowImgVideoFragment


/**
 *作者:LiBW
 *创建日期: 2021/7/6
 *描述:横向图片展示
 */
class ImageRecyclerViewAdapter (private val context: AppCompatActivity, private val imageList: List<String>) : RecyclerView.Adapter<ImageRecyclerViewAdapter.ViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_image_service_list, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = imageList[position]
        Glide.with(context).load(data).into(holder.mImageView)
        holder.mImageView.setOnClickListener {
//            ShowImageDialog(data).show(context.supportFragmentManager,"")
            ShowImgVideoFragment(data).show(context.supportFragmentManager,"")
        }
    }

    override fun getItemCount(): Int {
        return imageList.size
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mImageView: ImageView = itemView.findViewById(R.id.mImageView)
    }


}